package roborally.model.evaluables;

import java.util.*;

/**
 * A class that implements the interface Evaluable, representing a disjunction of Evaluables.
 * Thereby a Disjunction is always associated with a list of Evaluables.
 */
public class Disjunction extends ComposedCondition implements Evaluable{

	/**
	 * A list of associated Evaluables.
	 */
	private final List<Evaluable> evaluables;
	
	public Disjunction(List<Evaluable> evaluables){
		this.evaluables = evaluables;
	}
	
	/**
	 * @return The disjunction of the results of the evaluaton of each of the associated Evaluables. 
	 */
	@Override
	public boolean evaluate() {
		for(Evaluable evaluable : evaluables)
			if(evaluable.evaluate()) return true;
		return false;
	}
	
}